home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacHack 1997
/
MacHack 1997.toast
/
Hacks
/
Hacks ’93
/
ChooserHack
/
ChooserHackGlue.a
< prev
next >
Wrap
Text File
|
1993-06-15
|
7KB
|
319 lines
;
; File: ChooserHackGlue.a
;
; Contains: Patches to call routines in ChooserHack.c
;
; Written by: Nick Kledzik
;
; Date: June 93
;
; For: MacHack 93
;
;
CASE ON
include 'Traps.a'
include 'SysEqu.a'
INITStart PROC EXPORT
IMPORT DoInstall
lea INITStart,a0
_RecoverHandle , sys
_HLock
move.l a0,-(sp)
_DetachResource
bra DoInstall
ENDP
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Patch to _HFSDispatch
;
; Use to catch the Finder enumerating the items in a folder.
; Records the last folder the Finder enumerated (for use by SetWTitle patch).
;
;
HFSPatch PROC EXPORT
IMPORT SYNCSPECIALFOLDER
cmp.w #9,d0 ; only want D0.W = 9 (GetCatInfo)
bne.s @goOld2
cmp.l #'nick',32(a0) ; don't want to recurse
beq.s @goOld2
tst.w 28(a0) ; only want ioFDirIndex(A0) = 0
bne.s @goOld2
move.l $0910,d0
cmp.l #$0646696E,d0 ; only want to catch Finder calls
bne.s @goOld
pea ret ; fake JSR to old HFS dispatch to tail patch
@goOld
moveq #9,d0
@goOld2
move.l oldHFSDispatch,-(sp)
rts
EXPORT oldHFSDispatch
oldHFSDispatch
dc.l 0
EXPORT lastVRefNum, lastName
lastVRefNum dc.w 0
lastParID dc.l 0
lastName ds.b 32
ret
tst.w d0
bne.s @done ; do nothing if error
btst #4,30(a0) ; only care if a directory was found (ioFlAttrib bit 4)
beq.s @done
btst #0,84+9(a0) ; only care if it is one of my special folders
beq.s @done
movem.l a0-a1/d0,-(sp)
lea lastVRefNum,a1 ; copy info about what folder Finder was examining
move.w 22(a0),(a1)+
move.l 100(a0),(a1)+
move.l 18(a0),a0
moveq #(32/4)-1,d0
@loop move.l (a0)+,(a1)+
dbra d0,@loop
movem.l (sp)+,a0-a1/d0
@done rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Patch to _SetWTitle
;
; Use to catch the Finder creating a window.
; If the Finder is creating a window with the same name as the
; last folder enumerated, then the Finder is opening a folder.
;
WTitlePatch PROC EXPORT
EXPORT oldSetWTitle
IMPORT SYNCSPECIALFOLDER
IMPORT lastVRefNum, lastName
move.l $0910,d0
cmp.l #$0646696E,d0 ; only want to catch Finder calls
bne.s @done
move.l 4(SP),A0
lea lastName,A1
moveq #0,d0
move.b (a0),d0
@loop move.b (a1)+,d1
cmp.b (a0)+,d1 ; see if set window title to last searched folder
bne.s @done
subq.w #1,d0
bpl.s @loop
lea lastVRefNum,a0
move.w (a0)+,-(sp) ; SyncSpecialFolder( vRefNum, parID, name )
move.l (a0)+,-(sp)
move.l a0,-(sp)
bsr SYNCSPECIALFOLDER
@done move.l oldSetWTitle,a0
jmp (a0)
oldSetWTitle
dc.l 0
ENDP
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Patch to _HOpenResFile
;
; Use to catch the Finder opening an alias file.
; Initially the files created by ChooserHack to represent network volumes
; are empty, but have the alias bit set. If the Finder tries to get the
; alias resource out of one, HOpenResFile will fail. This patch catches
; that and calls OpenVolumeAliasFile to create the alias file
;
;
HOpenRFPatch PROC EXPORT
IMPORT OPENVOLUMEALIASFILE, lastEventOpen
move.b lastEventOpen,d0
beq.s @skip
move.l $0910,d0
cmp.l #$0646696E,d0 ; only want to catch Finder calls
beq.s @doit
@skip move.l oldHOpenResFile,a0
jmp (a0)
@doit link a6,#0
subq #2,sp
move.w 18(a6),-(sp)
move.l 14(a6),-(sp)
move.l 10(a6),-(sp)
move.w 8(a6),-(sp)
move.l oldHOpenResFile,a0
jsr (a0) ; tail patch HOpenResFile
move.w (sp)+,d0
cmp.w #-1,d0
bne.s @done ; only care if HOpenResFile returns -1
move.w #-39,d1
cmp.w $0A60,d1 ; ResErr
bne.s @done ; only care if ResErr is -39
subq #2,sp
move.w 18(a6),-(sp)
move.l 14(a6),-(sp)
move.l 10(a6),-(sp)
jsr OPENVOLUMEALIASFILE
move.w (sp)+,d0
@done move.w d0,20(a6)
unlk a6
move.l (sp)+,a0
add #12,sp
jmp (a0)
EXPORT oldHOpenResFile
oldHOpenResFile
dc.l 0
ENDP
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Patch to jGNEfilter
;
; Use to catch the Finder opening an alias file.
; Unfortunately, the Finder tries to open alias files for reasons other
; than opening. To have the HOpenResFile patch only effect the
; Finder trying to open alias, this jGNEfilter remembers if the last user
; event was a double-click or Cmd-O.
;
MyEventFilter PROC EXPORT
movem.l d0/a0,-(sp)
move.w evtNum(a1),d0
; look for Cmd-O keydown
cmp.w #keyDwnEvt,d0
bne.s @notKey
move.l evtMessage(a1),d0
cmp.b #'o',d0
bne.s @clrFlag
btst #cmdKey,evtMeta(a1)
beq.s @clrFlag
@setFlag lea lastEventOpen,a0
st (a0)
bra.s @done
; look for double click
@notKey cmp.w #mButDwnEvt,d0
bne.s @notMouseDwn
lea lastMouseTicks,a0
move.l (a0),d0
move.l evtTicks(a1),(a0)
add.l DoubleTime,d0
cmp.l (a0),d0
bhi.s @setFlag
bra.s @clrFlag
; look for update event
@notMouseDwn cmp.w #updatEvt,d0
bne.s @done ; update event clears flag
@clrFlag lea lastEventOpen,a0
sf (a0)
@done movem.l (sp)+,d0/a0
move.l oldjGNEFilter,-(sp)
bne.s @ok ; only call next filter if there is one
addq #4,sp
@ok rts
EXPORT oldjGNEFilter, lastEventOpen
lastMouseTicks dc.l 0
oldjGNEFilter dc.l 0
lastEventOpen dc.b 0
ENDP
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Install all the patches.
;
InstallPatches PROC EXPORT
; install HFSDispatch patch
IMPORT HFSPatch, oldHFSDispatch
move.w #$060,d0
_GetTrapAddress , newOS
lea oldHFSDispatch,a1
move.l a0,(a1)
move.w #$060,d0
lea HFSPatch,a0
_SetTrapAddress , newOS
; install SetWTitle patch
IMPORT WTitlePatch, oldSetWTitle
move.w #$011A,d0
_GetTrapAddress , newTool
lea oldSetWTitle,a1
move.l a0,(a1)
move.w #$011A,d0
lea WTitlePatch,a0
_SetTrapAddress , newTool
; install HOpenResFile patch
IMPORT HOpenRFPatch, oldHOpenResFile
move.w #$001A,d0
_GetTrapAddress , newTool
lea oldHOpenResFile,a1
move.l a0,(a1)
move.w #$001A,d0
lea HOpenRFPatch,a0
_SetTrapAddress , newTool
; install jGNE filter
IMPORT MyEventFilter, oldjGNEFilter
move.l JGNEFilter,a0
lea oldjGNEFilter,a1
move.l a0,(a1)
lea MyEventFilter,a0
move.l a0,JGNEFilter
rts
ENDP
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Glue to access globals
;
;
GetGlobals PROC EXPORT
lea globals,a0
move.l a0,d0
rts
globals ds.b 6
ENDP
END